package cn.itcast.com.Thread;
/*
三个窗口售票，互不影响，同时进行
三个窗口共同出售这100张电影票

三个线程模拟三个窗口
三个窗口共享100
 */
public class shop01 {
    public static void main(String[] args) {
        SalesWindow salesWindow1 = new SalesWindow();
        SalesWindow salesWindow2 = new SalesWindow();
        SalesWindow salesWindow3 = new SalesWindow();
        salesWindow1.start();
        salesWindow2.start();
        salesWindow3.start();
//        salepath salepath1 = new salepath();
//        Thread thread1 = new Thread(salepath1);
//        Thread thread2 = new Thread(salepath1);
//        Thread thread3 = new Thread(salepath1);
//        thread1.start();
//        thread2.start();
//        thread3.start();
    }
}

class SalesWindow extends Thread{

    static int tickets = 100;
    @Override
    public void run(){

        while (tickets > 0){
            System.out.println(getName()+": 售出了第"+tickets--+"张票");
        }
    }
}

class salepath implements Runnable {

    int tickets = 100;
    @Override
    public void run() {
        while (tickets > 0){
            System.out.println(Thread.currentThread().getName()+": 售出了第"+tickets--+"张票");
        }
    }
}